{
  "metadata": {
    "kernelspec": {
      "name": "xpython",
      "display_name": "Python 3.13 (XPython)",
      "language": "python"
    },
    "language_info": {
      "name": ""
    }
  },
  "nbformat_minor": 5,
  "nbformat": 4,
  "cells": [
    {
      "id": "22aac8e8-1970-4136-ab3f-3d5de14e1a13",
      "cell_type": "code",
      "source": "import qutip as qt\nimport numpy as np\nimport pandas as pd\n\n# Parameters (normalized units: omega_0=1 corresponds to ~1/ps scale; real omega_0 ~2.33e15 rad/s for 808 nm)\nomega_0 = 1.0  # Normalized energy splitting\nomega_L = 1.0  # Resonant laser frequency\nOmega_values = [0.05, 0.1, 0.2, 0.5]  # Rabi frequencies (proxy for fluence, 1-10 J/cm² range)\ngamma_values = [0.05, 0.1, 0.2]  # Decoherence rates (femtosecond to picosecond scales)\ntimes = np.linspace(0, 50, 500)  # Normalized time (scalable to ps)\n\n# Operators for TLS\nsz = qt.sigmaz()\nsm = qt.sigmam()\nsp = qt.sigmap()\n\n# Simulation function for a given parameter set\ndef run_simulation(Omega, gamma):\n    H = (omega_0 / 2) * sz + (Omega / 2) * (sp + sm)  # Resonant Hamiltonian\n    c_ops = [np.sqrt(gamma) * sm]  # Dissipation via spontaneous emission\n    rho0 = qt.basis(2, 0) * qt.basis(2, 0).dag()  # Initial ground state\n    result = qt.mesolve(H, rho0, times, c_ops=c_ops)\n    pop_excited = qt.expect(sp * sm, result.states)  # Excited population\n    coherence = np.real(qt.expect((sp + sm)/2, result.states))  # Real part of coherence\n    return pd.DataFrame({\n        'Time': times,\n        'Excited_Population': pop_excited,\n        'Coherence': coherence,\n        'Omega': Omega,\n        'Gamma': gamma\n    })\n\n# Parametric sweep\ndata_list = []\nfor Omega in Omega_values:\n    for gamma in gamma_values:\n        df = run_simulation(Omega, gamma)\n        data_list.append(df)\n\nfull_data = pd.concat(data_list, ignore_index=True)\n\n# Export full dataset to CSV for verification\nfull_data.to_csv('tls_parametric_sweep_data.csv', index=False)\n\n# Print sample output (first 5 rows of the first parameter set)\nprint(full_data[full_data['Omega'] == 0.05].head())",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    },
    {
      "id": "d4c6f2ab-1803-4920-a2c4-a3c2a7eb49f4",
      "cell_type": "code",
      "source": "",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    }
  ]
}